package com.stephenone.zhdaily.data.source.remote;

import com.google.common.base.Optional;
import com.stephenone.zhdaily.data.api.ZhiHuDailyApiHelper;
import com.stephenone.zhdaily.data.api.ZhihuNewsService;
import com.stephenone.zhdaily.data.bean.Comments;
import com.stephenone.zhdaily.data.source.CommentsDataSource;

import io.reactivex.Flowable;

/**
 * Created by Administrator on 2018/3/14.
 */

public class CommentsRemoteDataSource implements CommentsDataSource {
    private static CommentsRemoteDataSource INSTANCE;

    public static CommentsRemoteDataSource getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new CommentsRemoteDataSource();
        }
        return INSTANCE;
    }

    @Override
    public Flowable<Optional<Comments>> getLongComments(long storyId) {
        return ZhiHuDailyApiHelper.sService.getLongComments(storyId)
                .map(Optional::of);
    }

    @Override
    public Flowable<Optional<Comments>> getShortComments(long storyId) {
        return ZhiHuDailyApiHelper.sService.getShortComments(storyId)
                .map(Optional::of);
    }

    @Override
    public Flowable<Optional<Comments>> getBeforeComments(long storyId, long beforeCommentId) {
        return ZhiHuDailyApiHelper.sService.getShortCommentsBefore(storyId,beforeCommentId)
                .map(Optional::of);
    }
}
